package com.example.ktdome

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import android.widget.TextView

class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)


    }

    //定义一个变量sum给下面使用
    var sum = 0;

    /**
     * 递增
     */
    fun increment(view: View) {

        sum++;

        showScores(sum)

    }


    fun decrement(view: View) {

        sum = 0
        showScores(sum)

    }


    private fun showScores(sum: Int) {

        val textView: TextView = findViewById(R.id.textView);
        val text: String = sum.toString();
        textView.setText(text)
    }


}